import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { BaseItem } from "../common/BaseItem";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GiftBagInfo } from "../../model/GiftBagInfo";
import { ItemData } from "../../resource/info/ItemData";
//class KingRewardItemRenderer
    
    export  class KingRewardItemRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public get item(): BaseItem
        {
            return this._item;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createBg(0, 0, 38, 38, this, ImagesConst.PackItemBg);
            this._bmQue = ObjCreate.createBitmap("", 12, 6, this);
            this._bmQue.visible = false;
            this._item = new BaseItem();
            this._item.setSize(32, 32);
            this._item.move(3, 3);
            this._item.isDragAble = false;
            this._item.isDropAble = false;
            addChild(this._item);
            LoaderHelp.addResCallBack(ResFileConst.kingWar, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._bmQue.bitmapData = GlobalClass.getBitmapData(ImagesConst.kingWar_litYellowQue);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            super.data = arg1;
            if (arg1 != null) 
            {
                if (typeof arg1 === "giftbaginfo") 
                {
                    loc1 = arg1 as GiftBagInfo;
                    this._item.amount = loc1.num;
                    this._itemData = loc1.item;
                    this._item.itemData = this._itemData;
                    this._bmQue.visible = false;
                }
                else if (arg1.data == 0) 
                {
                    this._itemData = null;
                    this._item.itemData = null;
                    this._bmQue.visible = true;
                }
            }
            return;
        }

        /* internal */ /* var */_item: BaseItem;

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_bmQue: Object /* flash.display.Bitmap */;
    }
